package cn.itsource.basic.util;

import cn.itsource.org.domain.Employee;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * 抽取了一个spring服务类
 */
@Component //交给spring容器管理
//只要交给spring容器管理 ,可以注入来用了
public class EmailService {

    /**
     * spring注册的发邮件的核心类
     */
    @Autowired
    private JavaMailSender javaMailSender;

    public void sendEmail(String title,String text,String to){
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人 //抽常量
        mailMessage.setFrom("772593817@qq.com");
        //邮件主题
        mailMessage.setSubject(title);
        //邮件内容
        mailMessage.setText(text);
        //收件人
        mailMessage.setTo(to);

        javaMailSender.send(mailMessage);
    }

}
  